import Vue from 'vue';
import Router from 'vue-router';
import Login from '@/components/Login';
import RegisterInfo from '@/components/RegisterInfo';
import RegisterInfoList from '@/components/RegisterInfoList';
import Member from '@/components/Member';
import MemberList from '@/components/MemberList';
import Employer from '@/components/Employer';
import EmployerList from '@/components/EmployerList';
import SignInfo from '@/components/SignInfo';
import SignInfoList from '@/components/SignInfoList';

Vue.use(Router);
const router = new Router({
  routes: [{
    path: '/',
    name: 'Login',
    component: Login
  }, {
    path: '/registerInfo',
    name: 'RegisterInfo',
    component: RegisterInfo
  }, {
    path: '/registerInfoList',
    name: 'RegisterInfoList',
    component: RegisterInfoList
  }, {
    path: '/member',
    name: 'Member',
    component: Member
  }, {
    path: '/memberList',
    name: 'MemberList',
    component: MemberList
  }, {
    path: '/employer',
    name: 'Employer',
    component: Employer
  }, {
    path: '/employerList',
    name: 'EmployerList',
    component: EmployerList
  }, {
    path: '/signInfo',
    name: 'SignInfo',
    component: SignInfo
  }, {
    path: '/signInfoList',
    name: 'SignInfoList',
    component: SignInfoList
  }]
});

router.beforeEach((to, from, next) => {
  const toDepth = to.path.split('/').length
  const fromDepth = from.path.split('/').length
  if (toDepth < fromDepth) {
    console.log('后退。。。')
    from.meta.keepAlive = false
    to.meta.keepAlive = true
  }
  next()
})


export default router
